<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>

<style type="text/css">
.order_search {
	width: 228px;
	padding: 20px 5px;
	margin: 0px;
	padding: 0px;
	font-size: 12px;
	font-family: "Microsoft YaHei", '微软雅黑', 'Simsun', Verdana, Arial,
		Helvetica, sans-serif;
	color: #666;
}

.order_search ul {
	float: left;
	width: 228px;
}

ul {
	list-style: none;
}

.clr {
	clear: both;
	width: 0px;
	height: 0px;
	line-height: 0px;
	font-size: 0px;
}

.Search_operate {
	border-top: 1px dotted #ccc;
	text-align: right;
	line-height: 24px;
	/* padding-top: 8px; */
	/* margin-top: 30px; */
}
/* 强制一个高度，这样标签页就不会随着内容高度的改变而改变 */
.ui-tabs .ui-tabs-nav {
	clear: left;
	padding: 0 .2em .2em .2em;
}

.ui-tabs .ui-tabs-nav li {
	top: auto;
	bottom: 0;
	margin: 0 .2em 1px 0;
	border-bottom: auto;
	border-top: 0;
	border-bottom-width: 1px;
}

.ui-tabs .ui-tabs-panel {
	padding-top: 1px;
	padding-left: 10px;
	padding-bottom: 0px;
}
.ui-tabs .ui-tabs-nav .ui-tabs-anchor{
	float: left;
	padding: .1em 1em;
	text-decoration: none;
}
.ui-widget-content {
/* 	background: #00B895 !important;  */
	/* 	#58B4C3 */
	font-size: 12px;
}

ul li{
	margin-top: 5px;
}
</style>
</head>
<body>
	<div id="tabs">
		<ul>
			<li><a href="#tabs-1">拉单日志 </a></li>
			<li><a href="#tabs-2">同步订单日志 </a></li>
		</ul>
		<div id="tabs-1">
			<div class="order_find_cls">
				<table class="layout_tab">
					<tr>
						<td valign="top">
							<div class="order_search ui-widget-content">
								<ul>
									<li>
										<div class="title">客户号：</div>
										<div class="event">
											<input type="text"  
												id="cm_code" class="input_text input_cookie"
												style="width: 120px;">
										</div>
										<div class="clr"></div>
									</li>
									<li>
										<div class="title">店铺代码：</div>
										<div class="event">
											<input  id="cs_code" type="text" name="conditionVo.sku" value="" 
												class="input_text input_cookie" style="width: 120px;">
										</div>
										<div class="clr"></div>
									</li>
									<li>
										<div class="title">平台归属：</div>
										<div class="event">
											<select id="platform_code" class="input_text2 input_cookie"
												style="width: 120px;">
												<option value="">-- 全部 --</option>
												<option value="E">Ebay</option>
												<option value="A">亚马逊</option>
												<option value="S">速卖通</option>
											</select>


										</div>
										<div class="clr"></div>
									</li>
									<li>
										<div class="title">拉单结果：</div>
										<div class="event">
											<select id=pull_sign class="input_text2 input_cookie"
												style="width: 120px;">
												<option value="">-- 全部 --</option>
												<option value="Y">成功</option>
												<option value="N">失败</option>
											</select>


										</div>
										<div class="clr"></div>
									</li>
									<li>
										<div class="title">拉单时间：</div>
										<div class="event">
											<input type="text" id="pull_date_begin"
												size="15" maxlength="35" value="" 
												class="input_text input_cookie"
												style="font-size: 10px; line-height: 13px; width: 54px; cursor: pointer;"
												onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',el:$dp.$('pull_date_begin'),startDate:'{%y}-%M-{%d-31}',maxDate:'{%y}-%M-{%d}',readOnly:true})"/>
											- <input type="text" id="pull_date_end"
												size="15" maxlength="35" value="" 
												class="input_text input_cookie"
												style="font-size: 10px; line-height: 13px; width: 54px; cursor: pointer;"
												onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',el:$dp.$('pull_date_end'),startDate:'{%y}-%M-{%d}',maxDate:'{%y}-%M-{%d}',readOnly:true})"/>
										</div>
										<div class="clr"></div>
									</li>
								</ul>
								<div class="clr"></div>
								<div class="Search_operate">
									<input name="pullOrder_log_btnClean" id="pullOrder_log_btnClean" type="button" value="清 空"
										class="publicBtn"
										style="margin-top: 30px; margin-right: 20px; margin-bottom: 20px;">
									<input id="pullOrder_log_btnQuery" name="pullOrder_log_btnQuery" type="button" value="查 询"
										class="publicBtn2"
										style="margin-top: 30px; margin-right: 20px; margin-bottom: 20px;">
								</div>
							</div>
						</td>

						<td>
							<div>
								<table id="pullOrder_log_grid"></table>
								<div id="pullOrder_log_pager"></div>
							</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div id="tabs-2">
			<div class="order_find_cls">
				<table class="layout_tab">
					<tr>
						<td valign="top">
							<div class="order_search ui-widget-content">
								<ul>
									<li>
										<div class="title">引用单号：</div>
										<div class="event">
											<input type="text"   id="sync_ref_code"
												id="roReferenecode" class="input_text input_cookie"
												style="width: 120px;"/>
										</div>
										<div class="clr"></div>
									</li>
									<li>
										<div class="title">创建时间：</div>
										<div class="event">
											<input type="text" id="sync_createdate_start"
												size="15" maxlength="35" value="" 
												class="input_text input_cookie"
												style="font-size: 10px; line-height: 13px; width: 54px; cursor: pointer;"
												onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',el:$dp.$('sync_createdate_start'),startDate:'{%y}-%M-{%d-31}',maxDate:'{%y}-%M-{%d}',readOnly:true})"/>
											- <input type="text" id="sync_createdate_end"
												size="15" maxlength="35" value="" 
												class="input_text input_cookie"
												style="font-size: 10px; line-height: 13px; width: 54px; cursor: pointer;"
												onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',el:$dp.$('sync_createdate_end'),startDate:'{%y}-%M-{%d}',maxDate:'{%y}-%M-{%d}',readOnly:true})"/>
										</div>
										<div class="clr"></div>
									</li>
								</ul>
								<div class="clr"></div>
								<div class="Search_operate">
									<input name="syncOrderlog_btnClean" id="syncOrderlog_btnClean" type="button" value="清 空"
										class="publicBtn"
										style="margin-top: 30px; margin-right: 20px; margin-bottom: 20px;">
									<input id="syncOrderlog_btnQuery" name="syncOrderlog_btnQuery" type="button" value="查 询"
										class="publicBtn2"
										style="margin-top: 30px; margin-right: 20px; margin-bottom: 20px;">
								</div>
							</div>
						</td>

						<td>
							<div>
								<table id="syncOrderlog_grid"></table>
								<div id="syncOrderlog_pager"></div>
							</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
	<div id="pullOrder_log_dialog" title="拉单错误信息" style="display: none">
	</div>
	<div id="syncOrder_log_dialog" title="同步订单错误信息" style="display: none">
	</div>
</body>

<script type="text/javascript">
	$(function() {
		$("#tabs").tabs({
			active : 0
		});
	
		$(".showPullOrderLogfailure").live('click',function(){
			var pull_error_div =$(this)['context']['innerHTML'];
			var pull_error_msg=$(pull_error_div).text();
			$("#pullOrder_log_dialog").html(pull_error_msg);
			$( "#pullOrder_log_dialog" ).dialog({
				width:400,
				height:270
			});
		 });
		
		$(".showSyncOrderLogfailure").live('click',function(){
			var syn_error_div =$(this)['context']['innerHTML'];
			var syn_error_msg=$(syn_error_div).text();
			$( "#syncOrder_log_dialog" ).html(syn_error_msg);
			 $( "#syncOrder_log_dialog" ).dialog({
				width:630,
				height:350
			});
		 });
		
		
		/**
		 * 拉单日志条件查询
		 */
		$("#pullOrder_log_btnClean").button().click(function(event) {
			$("#cm_code").val("");
			$("#cs_code").val("");
			$("#platform_code").val("");
			$("#pull_sign").val("");
			$("#pull_date_begin").val("");
			$("#pull_date_end").val("");
		});
		$("#pullOrder_log_btnQuery").button().click(function(event) {
			var cm_code=$("#cm_code").val();
			var cs_code=$("#cs_code").val();
			var pull_sign=$("#pull_sign").val();
			var platform_code=$("#platform_code").val();
			var pull_date_begin=$("#pull_date_begin").val();
			var pull_date_end=$("#pull_date_end").val();
			var param={'cm_code':cm_code
						,'cs_code':cs_code
						,'pull_sign':pull_sign
					    ,'platform_code':platform_code
					    ,'pull_date_begin':pull_date_begin
					    ,'pull_date_end':pull_date_end};
			
			$("#pullOrder_log_grid").jqGrid('setGridParam',{
				postData:param
				}).trigger("reloadGrid");
		});
		
		/**
		 * 货品条件查询
		 */
		$("#syncOrderlog_btnClean").button().click(function(event) {
			$("#sync_ref_code").val("");
			$("#sync_createdate_start").val("");
			$("#sync_createdate_end").val("");
		});
		$("#syncOrderlog_btnQuery").button().click(function(event) {
			var sync_ref_code=$("#sync_ref_code").val();
			var sync_createdate_start= $("#sync_createdate_start").val();
			var sync_createdate_end=$("#sync_createdate_end").val();
			var param={'ref_code':sync_ref_code
					   ,'createdate_start':sync_createdate_start
					   ,'createdate_end':sync_createdate_end
					  };
			
			$("#syncOrderlog_grid").jqGrid('setGridParam',{
				postData:param
				}).trigger("reloadGrid");
		});
		
		
		
		
		
		var h = $("#main_center").height();
		var w = $("#main_center").width()-258;
		//当浏览器大小变化时
		$(window).resize(function() {
			h = $("#main_center").height();
			w = $("#main_center").width()-258;
			$(".ui-jqgrid-bdiv").css('height', h - (h * 0.22));
			$("#pullOrder_log_grid").setGridWidth(w);
		});
		
		//拉单日志grid
		$("#pullOrder_log_grid").jqGrid(
				{
					url : '${ctx}/log/findPullOrderLogPage.action',
					datatype : "json",
					mtype:'POST',
					colNames : [ '主键','失败信息','客户ID','客户号', '店铺代码','店铺名称', '平台代码', '拉单结果',
								 '拉单开始时间', '拉单结束时间', '创建时间'
							    ],
					colModel : [ 
					 {name : 'pol_id',index : 'pol_id',width : 55,hidden:true},
					 {name : 'error_msg',index : 'error_msg',width : 55,hidden:true},
					 {name : 'fk_cm_id',index : 'fk_cm_id',width : 150,align : "center"},
					 {name : 'cm_code',index : 'cm_code',width : 150,align : "center",sortable : false}, 
					 {name : 'fk_cs_code',index : 'fk_cs_code',width : 150,align : "center"},
					 {name : 'cs_name',index : 'cs_name',width : 150,align : "center",sortable : false},
					 {name : 'cs_platform_code',index :'cs_platform_code',width : 80,align : "center"},
					 {name : 'pull_sign',index :'pull_sign',width : 80,align : "center"
						 ,formatter:function(cellvalue, options, rowObject){
						  	if(cellvalue=='Y'){
						  		return "<font color='green' >成功</font>";
						  	}else{
						  		var error_msg=rowObject['error_msg'];
						  		return "<a class='showPullOrderLogfailure'  style='cursor:pointer;'>"
						  		+"<div style='display: none;'>"+error_msg+"-</div>"
						  		+"<font color='red' >失败</font></a>";
						  	}
					 	}
					 }, 
					 {name : 'pull_date_begin',index : 'pull_date_begin',width : 150,sortable : true
						 ,formatter:function(cellvalue, options, rowObject){
						 return $.global.formatDateT(cellvalue);
					 	}
					 } ,
					 {name : 'pull_date_end',index : 'pull_date_end',width : 150,sortable : true
						 ,formatter:function(cellvalue, options, rowObject){
						 return $.global.formatDateT(cellvalue);
					 	}
					 } ,
					 {name : 'create_date',index : 'create_date',width : 150,sortable : true
						 ,formatter:function(cellvalue, options, rowObject){
							 return $.global.formatDateT(cellvalue);
						 }
					 }, 
					],
					rowNum : 10,
					rowList : [ 10, 20, 30 ],
					pager : '#pullOrder_log_pager',
					sortname : 'create_date',
					rownumbers:true,
					rownumWidth:25,
					viewrecords : true,
					viewsortcols:[true,'vertical',true],
					width:w,
					shrinkToFit:false,
					autoScroll: true, 
					sortorder : "desc",
					height : h - (h * 0.22)
				}).navGrid('#pullOrder_log_pager',{edit:false,add:false,del:false});
		
		
		
	   /**
		* 原始表货品grid
		*/
		$("#syncOrderlog_grid").jqGrid(
				{
					url : '${ctx}/log/findsyncOrderlogPage.action',
					datatype : "json",
					mtype:'POST',
					colNames : [ 
					             '主键', '引用单号', '中文描述', '英文描述','错误信息','创建时间'
							   ],
					colModel : [ 
					 {name : 'pf_al_id',index : 'pf_al_id',width : 55,hidden:true}, 
					 {name : 'ref_code',index : 'ref_code',width : 150}, 
					 {name : 'zn_content',index : 'zn_content',width : 250,align : "center"},
					 {name : 'en_content',index :'en_content',width : 250,align : "center"},
					 {name : 'error_msg',index :'error_msg',width : 200,align : "center",
						 formatter:function(cellvalue, options, rowObject){
						  if(cellvalue!=null && cellvalue!='') {
// 							  $( "#syncOrder_log_dialog" ).html(cellvalue);	
							 return "<a class='showSyncOrderLogfailure'  style='cursor:pointer;'>"
							 +"<div style='display: none;' class='syn_eror_msg'>"+cellvalue+"</div>"	
							 +"<font color='red' >查询错误信息</font>"
						  	 +"</a>";
						  }else{
							  return "";
						  }
					 }},
					 {name : 'createdate',index :'createdate',width : 200,align : "center",sortable : true,
						 formatter:function(cellvalue, options, rowObject){
						 return $.global.formatDateT(cellvalue);
					 }} 
					 ],
					rowNum : 10,
					rowList : [ 10, 20, 30 ],
					pager : '#syncOrderlog_pager',
					sortname : 'createdate',
					rownumbers:true,
					rownumWidth:25,
					viewrecords : true,
					viewsortcols:[true,'vertical',true],
					width:w,
					shrinkToFit:false,
					autoScroll: true, 
					sortorder : "desc",
					height : h - (h * 0.22)
				}).navGrid('#syncOrderlog_pager',{edit:false,add:false,del:false});
	});
</script>
<script type="text/javascript" src="${ctx}/js/edit_jqui_tabs.js"></script>
</html>